import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;

public class Empdetails extends HttpServlet
{
 public void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException ,IOException
 {
  
try
{ 
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  Connection con =   DriverManager.getConnection("jdbc:odbc:psi","psi","psi");
  System.out.println("connection is created"+con);
  String empcode=req.getParameter("empcode");
 int procode=Integer.parseInt(req.getParameter("procode").trim());
String ename=req.getParameter("ename");
String pname=req.getParameter("pname");
int gcode=Integer.parseInt(req.getParameter("gcode"));
String acttype=req.getParameter("acttype");

String submit=req.getParameter("vittu");

Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
if(submit.equals("Save"))
  	{

  PreparedStatement pstmt2=con.prepareStatement("insert into employee  values(?,?,?,?,?,?,?)");
                System.out.println("preparestatment is created"+pstmt2);
    	pstmt2.setString(1,empcode);
    	pstmt2.setString(2,ename);
                  pstmt2.setString(3,"");
                  pstmt2.setString(4,"");
                  pstmt2.setInt(5,procode);   	            
	pstmt2.setString(6,acttype);
                 pstmt2.setInt(7,gcode);
                 pstmt2.executeUpdate();
       

}   

resp.sendRedirect("timesheet-details.htm");
}
catch(Exception e)
{
 e.printStackTrace();
 }
}
 }